/**
 * Copyright &copy; 2012-2016 <a href="https://www.kaaction.com">KAA</a> All rights reserved All rights reserved.
 */
package com.kaaction.modules.mer.service;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.kaaction.common.persistence.Page;
import com.kaaction.common.service.CrudService;
import com.kaaction.modules.mer.entity.OperationContentDetail;
import com.kaaction.modules.mer.dao.OperationContentDetailDao;

/**
 * 精选商品推荐Service
 * @author huanghaiming
 * @version 2017-07-11
 */
@Service
@Transactional(readOnly = true)
public class OperationContentDetailService extends CrudService<OperationContentDetailDao, OperationContentDetail> {

	public OperationContentDetail get(String id) {
		return super.get(id);
	}
	
	public List<OperationContentDetail> findList(OperationContentDetail operationContentDetail) {
		return super.findList(operationContentDetail);
	}
	
	public Page<OperationContentDetail> findPage(Page<OperationContentDetail> page, OperationContentDetail operationContentDetail) {
		return super.findPage(page, operationContentDetail);
	}
	
	@Transactional(readOnly = false)
	public void save(OperationContentDetail operationContentDetail) {
		super.save(operationContentDetail);
	}
	
	@Transactional(readOnly = false)
	public void delete(OperationContentDetail operationContentDetail) {
		super.delete(operationContentDetail);
	}

	@Transactional(readOnly = false)
	public void insertOperaContentDtl(String id, String opecontId) {
		
		OperationContentDetail operationContentDetail = new OperationContentDetail();
		
		String[] ids = id.split(",");
		for(String productId:ids){
			int cnt = super.dao.setCnt(productId,opecontId);
			if(cnt==0){
				operationContentDetail.setProductId(productId);
				operationContentDetail.setOpercontentId(opecontId);
				operationContentDetail.preInsert();
				super.dao.insert(operationContentDetail);
			}
		}
		
	}

	@Transactional(readOnly = false)
	public void updateOpeContentTitle(OperationContentDetail operationContentDetail) {
		super.dao.updateOpeContentTitle(operationContentDetail);
	}

}